layui.use(['form', 'admin', 'ax', 'laydate', 'upload', 'formSelects', 'layer', 'table'], function () {
    var $ = layui.jquery;
    var $ax = layui.ax;
    var form = layui.form;
    var admin = layui.admin;
    var layer = layui.layer;
    var table = layui.table;

    $("#returnBefore").click(function () {
        history.go(-1)
    })

    /**
     * 先获取表中数据
     */
    var ajax = new $ax(Feng.ctxPath + '/metadata/listMetadata?tableName=' + Feng.getUrlParam("tableName"))
    var result = ajax.start()
    // console.log(result.data)

    var keys = Object.keys(result.data[0])
    // console.log(keys)

    var arr = [];
    for (var i = 0; i < keys.length; i++) {
        arr.push({field: keys[i], sort: false, title: keys[i], align: "center"})
    }

    // console.log(arr)


    /**
     * 管理表
     */
    var detail = {
        tableId: "detailTable"
    };

    /**
     * 表初始化列
     */

    detail.initColumn = function () {
        return [arr];
    };

    var tableResult = table.render({
        elem: '#' + detail.tableId,
        url: Feng.ctxPath + '/metadata/listMetadata?tableName=' + Feng.getUrlParam("tableName"),
        page: true,
        height: "full-158",
        cellMinWidth: 100,
        skin: 'line',
        cols: detail.initColumn(),
        done: function (res, curr, count) {
            $('tr').css('background-color', '#ffffff')
        }
    });

});